package HelperClasses;

/**
 *
 * @author johannes
 */
public class Vektor {

    private double x;
    private double y;

    public Vektor() {
        this.x = 0;
        this.y = 0;
    }
    
    public Vektor(double x, double y) {
        this.x = x;
        this.y = y;
    }

    public Vektor(int x, int y) {
        this.x = x;
        this.y = y;
    }

    public double getX() {
        return x;
    }
    
    public int getXInt() {
        return (int)x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public int getYInt() {
        return (int)y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getLength() {
        return Math.abs(Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));
    }

    public double multiply(Vektor v2) {
        return this.x * v2.x + this.y * v2.y;
    }

    public void enlarge(double factor) {
        this.x = this.x * factor;
        this.y = this.y * factor;
    }

    public void makeUnitVector() {
        enlarge(1 / getLength());
    }

    public Vektor getUnitVector() {
        return new Vektor(this.x / getLength(), this.y / getLength());
    }
}
